#define _CRT_SECURE_NO_WARNINGS 1

#include"Heap.h"

void test()
{
    Heap hp;
    HeapInit(&hp);
    HeapPush(&hp, 1);
    HeapPush(&hp, 2);
    HeapPush(&hp, 3);
    HeapPush(&hp, 4);
    HeapDestroy(&hp);
}

void HeapSort(int* arr, int n)
{
    int i = 0;
    for (i = 0; i < n; i++)
    {
        AdjustUp(arr, i);
    }
    int end = n - 1;
    while (end > 0)
    {
        int temp = arr[0];
        arr[0] = arr[end];
        arr[end] = temp;
        AdjustDown(arr, 0, end--);
    }
}

int main()
{
    //test();
    int arr[] = { 1,2,3,4,5,10,9,8,7,6 };
    HeapSort(arr, 10);
    for (int i = 0; i < 10; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}